package com.my.service.impl;

import com.my.dao.StockDao;
import com.my.pojo.Stock;
import com.my.service.IStockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;

@Service
public class StockServiceImpl implements IStockService {
    private StockDao stockDao;

    @Autowired
    public void setStockDao(StockDao stockDao) {
        this.stockDao = stockDao;
    }

    @Override
    public Integer in(Stock stock) {
        Stock save = this.stockDao.save(stock);
        if (save != null) {
            return save.getStockId();
        }
        return null;
    }

    @Override
    public Page<Stock> showAll(Pageable pageable, String context, Integer businessId) {
        return this.stockDao.queryByStock(context,businessId,pageable);
    }
}
